//===============================================================================
//	RankDataTable.h
//	
//===============================================================================

#pragma once

#include <unordered_map>
#include <vector>
#include "../share/user_define.h"

class RankData
{
	static const uint32_t name_lenth = 32;
public:
	RankData(void)
		: m_sn(0)
		, m_rankType(0)
		, m_updateTime(0)
		, m_showCount(0)
		, m_rankingBufferIdx(0)
		, m_scriptId(0)
		, m_valueLimit(0)
	{
		_mem_zero(m_rankName, name_lenth);
	}

	~RankData(void)
	{}

public:
	void Clear(void)
	{
		m_sn = 0;
		m_rankType = 0;
		m_updateTime = 0;
		m_showCount = 0;
		m_rankingBufferIdx = 0;
		m_scriptId = 0;
		m_valueLimit = 0;

		_mem_zero(m_rankName, name_lenth);
	}

public:
	uint32_t m_sn;
	uint32_t m_rankType;
	uint32_t m_updateTime;
	uint32_t m_showCount;
	uint32_t m_rankingBufferIdx;
	uint32_t m_scriptId;
	uint32_t m_valueLimit;
	char     m_rankName[name_lenth];
};

class RankDataTable
{
public:
	RankDataTable();
	~RankDataTable();

public:
	RankData* GetRankDataById(uint32_t id);

private:
	bool addToIndex(int32_t id, uint32_t idx);

private:
	std::vector<RankData> m_content;
	std::unordered_map<uint32_t, int32_t> m_index;
	uint32_t m_max_count;
};

